<template>
    <div class="header">
        <div class="logo">智能boss管理平台 &nbsp;&nbsp;&nbsp;&nbsp;</div>
        <div class="user-info">
            <el-dropdown trigger="click" @command="handleCommand">
                <span class="el-dropdown-link">
                    <img class="user-logo" src="../../../static/img/img.jpg">
                    {{username}}
                </span>
                <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item >退出</el-dropdown-item>
                </el-dropdown-menu>
            </el-dropdown>
        </div>
    </div>
</template>
<script>
    const insurance = require( '../../api/insurance.js');        //  接口js引用
    export default {
        data() {
            return {
                name: 'admin',
                username:'',
            }
        },
        computed:{
        },
        methods:{
            //  退出
            handleCommand() {
                var username = localStorage.getItem('ms_username');
                this.$message({ message: username +"已退出", type: 'success' });
                var rem = localStorage.getItem('ms_remember');
                if(rem == 'false'){
                    localStorage.removeItem('ms_username');
                    localStorage.removeItem('ms_usertime');
                    localStorage.removeItem('ms_remember');
                }
                this.$router.push('/userlogin');
            },
        },
        mounted(){
            let usernames = localStorage.getItem('ms_username');
            if(usernames == undefined || usernames == null || usernames == ''){
                this.handleCommand();
            }else{
                this.username = usernames;
            }
        }
    }
</script>
<style>
    @import "../../../static/css/main.css";
    @import "../../../static/css/theme-green2/color-green.css";  /* !*浅绿色主题*!*/
</style>
